﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Pampa.WebControls;

namespace Pampa.MVC.Fluent.CustomControls
{
    public class SelectorBuilder : IHtmlString
    {
        private readonly Selector _selector;

        public SelectorBuilder(string id)
        {
            _selector = new Selector();
            _selector.ID = id;
            _selector.CssClass = "selector";
        }

        public SelectorBuilder DataHandler(string dataHandler)
        {
            _selector.DataHandler = dataHandler;
            return this;
        }

        public SelectorBuilder EmptyText(string emptyText)
        {
            _selector.EmptyText = emptyText;
            return this;
        }

        public SelectorBuilder Width(int width)
        {
            _selector.Width = width;
            return this;
        }

        public SelectorBuilder Size(int size)
        {
            _selector.Size = size;
            return this;
        }

        public SelectorBuilder FreeText(bool value)
        {
            _selector.FreeText = value;
            return this;
        }

        public string ToHtmlString()
        {
            var sb = new StringBuilder();
            sb.Append(_selector.Render());

            return sb.ToString();
        }
    }
}
